#include "gtkwindow.h"
#include "gtkassistant.h"
#include "gtkintl.h"
+#include "gtkstylecontextprivate.h"
#include "gtkwidgetpath.h"
#include "a11y/gtkcontaineraccessible.h"
static gboolean
gtk_container_idle_sizer (gpointer data)
{
+ GSList *slist;
+
/* we may be invoked with a container_resize_queue of NULL, because
* queue_resize could have been adding an extra idle function while
* the queue still got processed. we better just ignore such case
* than trying to explicitely work around them with some extra flags,
* since it doesn't cause any actual harm.
*/
+
+ /* We validate the style contexts in a single loop before even trying
+ * to handle resizes instead of doing validations inline.
+ * This is mostly necessary for compatibility reasons with old code,
+ * because size_allocate functions often change styles and so could
+ * cause infinite loops in this function.
+ */
+ for (slist = container_resize_queue; slist; slist = slist->next)
+ {
+ _gtk_style_context_validate (gtk_widget_get_style_context (slist->data), 0);
+ }
+
while (container_resize_queue)
{
- GSList *slist;
GtkWidget *widget;
slist = container_resize_queue;
break;
case GTK_RESIZE_IMMEDIATE:
+ _gtk_style_context_validate (gtk_widget_get_style_context (GTK_WIDGET (resize_container)), 0);
gtk_container_check_resize (resize_container);
break;
GtkTextDirection direction;
GtkCssChange relevant_changes;
+ GtkCssChange pending_changes;
guint animations_invalidated : 1;
guint invalidating_context : 1;
+ guint invalid : 1;
};
enum {
return data;
}
+static void
+gtk_style_context_set_invalid (GtkStyleContext *context,
+ gboolean invalid)
+{
+ GtkStyleContextPrivate *priv;
+
+ priv = context->priv;
+
+ if (priv->invalid == invalid)
+ return;
+
+ priv->invalid = invalid;
+
+ if (invalid)
+ {
+ if (priv->widget)
+ gtk_widget_queue_resize (priv->widget);
+ if (priv->parent)
+ gtk_style_context_set_invalid (priv->parent, TRUE);
+ }
+}
+
/* returns TRUE if someone called gtk_style_context_save() but hasn't
* called gtk_style_context_restore() yet.
* In those situations we don't invalidate the context when somebody
{
parent->priv->children = g_slist_prepend (parent->priv->children, context);
g_object_ref (parent);
+ if (priv->invalid)
+ gtk_style_context_set_invalid (parent, TRUE);
}
if (priv->parent)
}
void
-_gtk_style_context_queue_invalidate (GtkStyleContext *context,
- GtkCssChange change)
+_gtk_style_context_validate (GtkStyleContext *context,
+ GtkCssChange change)
{
GtkStyleContextPrivate *priv;
+ GSList *list;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
- g_return_if_fail (change != 0);
priv = context->priv;
- if (priv->widget == NULL && priv->widget_path == NULL)
+ change |= priv->pending_changes;
+
+ if (!priv->invalid && change == 0)
return;
+ priv->pending_changes = 0;
+ gtk_style_context_set_invalid (context, FALSE);
+
/* Try to avoid invalidating if we can */
if (change & GTK_STYLE_CONTEXT_RADICAL_CHANGE)
{
gtk_widget_path_unref (path);
}
+ }
- if ((priv->relevant_changes & change) == 0)
- return;
+ if (priv->relevant_changes & change)
+ {
+ gtk_style_context_invalidate (context);
}
- gtk_style_context_invalidate (context);
+ change = _gtk_css_change_for_child (change);
+ for (list = priv->children; list; list = list->next)
+ {
+ _gtk_style_context_validate (list->data, change);
+ }
+}
+
+void
+_gtk_style_context_queue_invalidate (GtkStyleContext *context,
+ GtkCssChange change)
+{
+ GtkStyleContextPrivate *priv;
+
+ g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+ g_return_if_fail (change != 0);
+
+ priv = context->priv;
+
+ if (priv->widget == NULL && priv->widget_path == NULL)
+ return;
+
+ priv->pending_changes |= change;
+ gtk_style_context_set_invalid (context, TRUE);
}
/**